<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>模拟配置管理 |模拟新增配置管理</title>
<@fm.header />
<style>
.provinceClass label {
	font-size: 12px;
	float:left;
	margin:2px;
	width:80px;
	height:20px;
}
</style>
</head>
<body>
<div class="easyui-layout" style="text-align: center; height: 270px;" fit="true">
	<div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
	<form id="ff" method="post" enctype="multipart/form-data">
	<input type="hidden" name="mark"   value=${config.mark}></input>
	    <table>
	        <tr>
	            <td><label for="channelName">渠道名称:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="channelName"   value=${config.channelName}></input></td>
	            &nbsp;&nbsp;&nbsp;&nbsp;
	            <td><label for="apkName">apk名称:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="apkName"  value=${config.apkName}></input></td>
	        </tr>
			<tr>
	            <td><label for="retentRate">留存比例(0-100):</label></td>
	            <td><input id="retentRate" type="text" name="retentRate" value=${config.retentRate} ></input></td>
	            <td><label for="exeTimes">留存执行总次数:</label></td>
	            <td><input id="exeTimes" type="text" name="exetimes"  value=${config.exetimes}></input></td>
	        </tr>
	        <tr>
	           
	            <td><label for="currexetimes">当日登录次数:</label></td>
	            <td><input id="currexetimes" type="text" name="currexetimes"  value=${config.currexetimes}></input></td>
	              <td><label for="retentExetimes">单次留存执行次数:</label></td>
	            <td><input id="retentExetimes" type="text" name="retentExetimes" value=${config.retentExetimes}></input></td>
	        </tr>
	        <tr>
	            <td><label for="currRetentRate">当日再启动用户比例(0-100):</label></td>
	            <td><input id="currRetentRate" type="text" name="currRetentRate"  value=${config.currRetentRate}></input></td>
	         <td><label>基地</label></td>
	            <!--<td> <select class="easyui-combobox" name="base" panelHeight="auto" style="width:155px" value=${config.base}  data-options="required:true">
	                	<option value="1"<#if config.base?exists && config.base == 1>selected</#if>>动漫</option>
	                	<option value="0"<#if config.base?exists && config.base == 0>selected</#if>>音乐</option>
	                	<option value="2"<#if config.base?exists && config.base == 2>selected</#if>>视频</option>
	                	<option value="3"<#if config.base?exists && config.base == 3>selected</#if>>阅读</option>
	                	<option value="99"<#if config.base?exists && config.base == 99>selected</#if>>其他</option>
		            </select>
	    	 </td>-->
	    	 
	    	   <td><input id="cc" class="easyui-combobox" style="width: 155px;" name="base" data-options="
						required:true,
						url:'/base/content?defaultValues=${config.base}',
						method:'get',
						valueField:'id',
						textField:'baseName'" /></td>
	        </tr>
	          <tr>
	            <td><label for="retentDates">留存天数</label></td>
	            <td><input id="retentDates" type="text" name="retentDates"  value=${config.retentDates}></input></td>
	            <td><label for="smsinterfaceid">短信接口</label></td>
	            <td> <select class="easyui-combobox" name="smsinterfaceid" panelHeight="auto" style="width:155px"  value=${config.smsinterfaceid} data-options="required:true">
		                <option value="1"<#if config.smsinterfaceid?exists && config.smsinterfaceid == 1>selected</#if>>动漫</option>
	                	<option value="0"<#if config.smsinterfaceid?exists && config.smsinterfaceid == 0>selected</#if>>音乐</option>
	                	<option value="2"<#if config.smsinterfaceid?exists && config.smsinterfaceid == 2>selected</#if>>视频</option>
	                	<option value="3"<#if config.smsinterfaceid?exists && config.smsinterfaceid == 3>selected</#if>>阅读</option>
		            </select>
	    	 </td>
	        </tr>
	         <tr>
	            <td><label for="paycode">支付代码</label></td>
	            <td><input id="paycode" type="text" name="paycode" value=${config.paycode}></input></td>
	            <td><label for="phonenum">支付号码</label></td>
	            <td><input id="phonenum" type="text" name="phonenum" value=${config.phonenum}></input></td>
	        </tr>
	         <tr>
	        <td><label for="sendType">短信发送类型</label></td>
	            <td>
	            <select class="easyui-combobox" name="sendType" panelHeight="auto" style="width:155px" data-options="required:true">
	            		<option value="1"<#if config.sendType?exists && config.sendType == 1>selected</#if>>文本发送</option>
	                	<option value="0"<#if config.sendType?exists && config.sendType == 0>selected</#if>>数据类型发送</option>
		            </select>
	            </td>
	             <td><label for="daylimit">日限</label></td>
	            <td><input id="daylimit" type="text" name="daylimit" value=${config.daylimit}></input></td>
	        <tr>
	        <tr>
	            <td><label for="isneedLogin">是否需要混淆</label></td>
	            <td>
	            <select class="easyui-combobox" name="needLoginSuccess" panelHeight="auto" style="width:155px"   data-options="required:true">
		                <option value="1" <#if config.needLoginSuccess?exists && config.needLoginSuccess == 1>selected</#if>>需要SDK登录</option>
	                	<option value="0" <#if config.needLoginSuccess?exists && config.needLoginSuccess == 0>selected</#if>>代理登录</option>
	                	<option value="2" <#if config.needLoginSuccess?exists && config.needLoginSuccess == 2>selected</#if>>咪咕登录</option>
	                	<option value="3" <#if config.needLoginSuccess?exists && config.needLoginSuccess == 3>selected</#if>>代理或咪咕登录</option>
	                	<option value="4" <#if config.needLoginSuccess?exists && config.needLoginSuccess == 4>selected</#if>>验证码方式</option>
	                	
		            </select>
	            </td>
	            <td><label for="mixUserRate">混淆区间(0,100)</label></td>
	            <td><input id="mixUserRate" type="text" name="mixUserRate"  value=${config.mixUserRate}></input></td>
	        </tr>
	        
	        <tr>
		             <td><label for="isAssignDeviceType">是否指定机型</label></td>
		             <td>
		                 <input type="hidden" name="assignDeviceType" id="assignDeviceType" value=${config.assignDeviceType} />
		             	<label><input type="checkbox" id="isAssignDeviceTypeId"> </label>
		             </td>
		               <td><label for="needSendBackSMS">是否需要发短信</label></td>
		             <td>
		              <input type="hidden" name="needSendSms" id="needSendSms" value=${config.needSendSms} />
		             	<label><input type="checkbox"  id="isneedSendSms" > </label>
		             </td>
		   </tr>
	        
	        <tr>
	            <td><label for="apkUpload">apk上传:</label></td>
	            <td><input type="file" name="file" id="apk"></input></td>
	            <td><label for="jarUpload">jar包上传:</label></td>
	            <td><input type="file" name="file" id="jar"></input></td>
	        </tr>
	        <tr>
	            <td><label for="scriptUpload">脚本上传:</label></td>
	            <td><input type="file" name="file" id="script"></input></td>
	        </tr>
	         <tr>
	            <td><label for="isnewUserlimit">新增分时段:</label></td>
	            <td> <select class="easyui-combobox" name="isnewUserlimit" panelHeight="auto" style="width:155px" data-options="required:true">
	                	  <option value="0" <#if config.isnewUserlimit?exists && config.isnewUserlimit == true>selected</#if>>否</option>
	             	 	  <option value="1" <#if config.isnewUserlimit?exists && config.isnewUserlimit == true>selected</#if>>是</option>
		            </select></input></td>
	            <td><label for="isretentlimit">留存分时段:</label></td>
	            <td> <select class="easyui-combobox" name="isretentlimit" panelHeight="auto" style="width:155px" data-options="required:true">
	             			<option value="0" <#if config.isretentlimit?exists && config.isretentlimit == true>selected</#if>>否</option>
	              			<option value="1" <#if config.isretentlimit?exists && config.isretentlimit == true>selected</#if>>是</option>
		            </select></td>
	        </tr>
	        <tr>
 	            <td><label for="interceptId">拦截策略:</label></td>
	            <td colspan="3"><input id="interceptId" class="easyui-combogrid" formatter="formatterLabelId" style="width: 400px;height: 28px;" value="<#if config.interceptId?exists>${config.interceptId}</#if>" name="interceptId" data-options="
						panelWidth: 400,
						panelHeight: '150',
						multiple:true,
						multiline:true,
						url:'/interceptInfo/content?defaultValues=${config.interceptId}',
						method:'get',
						idField: 'id',
            			textField: 'msgContent',
						columns: [[
							{field:'id',title:'编号',width:30},
			                {field:'msgContent',title:'拦截策略',width:150},
			                {field:'regexContent',title:'正则表达式验证码',width:120}
			            ]],
            			fitColumns: true 
						"/>
	            </td>
	        </tr>	  
	    </table>
	</form>
	</div>
	<div region="south" border="false" style="text-align: center; padding: 5px 5px 5px 0;">
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="add()">提交</a>
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm();">重置</a>
	</div>
</div>

<script>

	$(function(){
		$('#interceptId').combogrid('setValues',[<#list interceptList as i>'${i.id}',</#list>]);
		if($("#assignDeviceType").val()==1){
			$("#isAssignDeviceTypeId").attr("checked","checked");
		}
		if($("#needSendSms").val()==1){
			$("#isneedSendSms").attr("checked","checked");
		}
	});
	
	
	$("#isAssignDeviceTypeId").on('click',function(){
		if ($("#isAssignDeviceTypeId").is(':checked')) {
			$("#assignDeviceType").val(1);
		} else {
			$("#assignDeviceType").val(0);
		}
	})
	
	$("#isneedSendSms").on('click',function(){
		if ($("#isneedSendSms").is(':checked')) {
			$("#needSendSms").val(1);
		} else {
			$("#needSendSms").val(0);
		}
	})

	
	
function add() {
	
	$('#ff').form(
	    'submit',
	    {
			url : '/channelapk/updateConfig',
			onSubmit : function() {
				/**
				var xlsName = $('#apk').val();
				if (xlsName.lastIndexOf('.apk') < 0) {
					top.showMsg(market.content.title, '导入格式应为apk格式', alert);
					return false;
				}
				$(this).attr("disabled", "disabled");*/
			},
			success : function(data) {
				showProcess(false);
				var data = eval('(' + data + ')');
				if (data.return_code == '1') {
					top.showMsg(market.content.title, data.return_msg, alert);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				}else if(data.return_code == '10'){
					$.messager.alert(market.content.title, data.return_msg);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				} else {
					$.messager.alert(market.content.title, data.return_msg);
				}
			},
			onLoadError : function() {
				showProcess(false);
				$.messager.alert(market.content.title, market.content.networkError);
			}
		}); 
}
</script>
</body>
</html>